package eu.reply.android.flashm.entities;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.json.JSONException;
import org.json.JSONObject;


public class EventFactory {

	protected static final String EVENT_ID="id";
	protected static final String NAME="name";
	protected static final String DATE="date";
	protected static final String LOCATION="location";
	protected static final String IMAGE="image";
	protected static final String DESCRIPTION="description";
	protected static final String UNOTIFIED="notified";
	protected static final String UATTENDING="attendees";
	protected static final String UREJECTED="urejected";
	
	public static Event parseJSON(String jsonString) throws JSONException{
		
		JSONObject json = new JSONObject(jsonString);
		int id=json.optInt(EVENT_ID, 0);
		String name = json.optString(NAME);
		String date = json.optString(DATE);
		String location = json.optString(LOCATION);
		int image = json.optInt(IMAGE);
		String description = json.optString(DESCRIPTION);
		
		Event event = new Event(id,name);
		//TODO remofe hardcoded date
		//SimpleDateFormat sdf = new SimpleDateFormat("ddMMyy-hhmmss");
		//date = sdf.format( new Date()).toString();
		event.setDate(new Date());
		event.setLatLongt(location);
		event.setImageResourceId(image);
		event.setDescription(description);
		
		return event;
	}
	
	
}
